package com.sanrenzu.chunbo.ui.foodagency;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.sanrenzu.chunbo.R;
import com.sanrenzu.chunbo.bean.gy.CateGoryListBean;

import java.util.List;

/**
 * Created by Administrator on 2016/8/31 0031.
 */
public class CateGoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private List<CateGoryListBean>list;
    private LayoutInflater inflater;
    public CateGoryAdapter(Context mContext,List<CateGoryListBean>list){
        this.mContext=mContext;
        this.list=list;
        inflater= (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }
    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view=inflater.inflate(R.layout.recycleview_category_foodagency,parent,false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyViewHolder mHolder= (MyViewHolder) holder;
        Glide.with(mContext)
                .load(list.get(position).getPicUrl())
                .into(mHolder.imageView_cateGory_foodAgency);
    }

    @Override
    public int getItemCount() {
        return list.size();
    }
    class MyViewHolder extends RecyclerView.ViewHolder{
        private ImageView imageView_cateGory_foodAgency;
        public MyViewHolder(View itemView) {
            super(itemView);
            imageView_cateGory_foodAgency=
                    (ImageView) itemView.findViewById(R.id.imageView_cateGory_foodAgency);
        }
    }
}
